package com.bp.hearthealth.pulse.lnapps.bp_db.bp_project

import androidx.room.TypeConverter
import com.bp.hearthealth.pulse.lnapps.bp_ui.bp_bean.LanguageItemBean
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import java.lang.reflect.Type


/**
 * @author: isnoam
 * @package_name: CommentTypeConverter.kt
 * @description：
 */
class BpTypeConverter {
    var gson = Gson()

    @TypeConverter
    fun stringToObjectList(data: String?): List<LanguageItemBean?>? {
        if (data == null) {
            return emptyList<LanguageItemBean>()
        }
        val listType: Type = object : TypeToken<List<LanguageItemBean?>?>() {}.type
        return gson.fromJson<List<LanguageItemBean?>>(data, listType)
    }

    @TypeConverter
    fun objectListToString(someObjects: List<LanguageItemBean?>?): String? {
        return gson.toJson(someObjects)
    }
}